include ../Makefile.inc

$(OBJ_DIR)/basic_http.o : basic_http.cpp $(INCLUDE_DIR)/tcetools/basic_http.h $(INCLUDE_DIR)/tcetools/socket.h $(INCLUDE_DIR)/tcetools/md5.h
	-mkdir -p $(OBJ_DIR)
	$(CXX) $(INCLUDES) $< -c -o $@
	
$(OBJ_DIR)/md5.o : md5.cpp md5.h
	-mkdir -p $(OBJ_DIR)
	$(CXX) $(INCLUDES) $< -c -o $@

$(INCLUDE_DIR)/tcetools/basic_http.h: basic_http.h
	-mkdir -p $(INCLUDE_DIR)/tcetools
	cp -f basic_http.h $(INCLUDE_DIR)/tcetools/
	
$(INCLUDE_DIR)/tcetools/md5.h: md5.h
	-mkdir -p $(INCLUDE_DIR)/tcetools
	cp -f md5.h $(INCLUDE_DIR)/tcetools/

$(INCLUDE_DIR)/tcetools/socket.h : force_look
	cd ../sockets; $(MAKE) $(MFLAGS)

clean :
	rm -f objs/*.o
	rm -f $(INCLUDE_DIR)/tcetools/basic_http.h
	rm -f test

test: $(OBJ_DIR)/main.o $(TOOLS_LIB_FILE)
	$(CXX) $< $(LIBS) -o test

$(OBJ_DIR)/main.o: main.cpp $(TOOLS_LIB_FILE)
	$(CXX) $(INCLUDES) $< -c -o $@

$(TOOLS_LIB_FILE) : force_look
	cd ..; $(MAKE) lib

force_look:
	true

lib: $(OBJ_DIR)/basic_http.o $(OBJ_DIR)/md5.o
	ar rsc $(TOOLS_LIB_FILE) $(OBJ_DIR)/basic_http.o $(OBJ_DIR)/md5.o
